/*   1:    */ package com.rinsi.util;
/*   2:    */ 
/*   3:    */ import java.io.IOException;
/*   4:    */ import java.io.OutputStream;
/*   5:    */ import java.util.Properties;
/*   6:    */ import javax.servlet.http.HttpServletResponse;
/*   7:    */ import org.smx.captcha.IBackgroundProducer;
/*   8:    */ import org.smx.captcha.Producer;
/*   9:    */ import org.smx.captcha.impl.FactorySimpleMathImpl;
/*  10:    */ import org.smx.captcha.impl.GridBackgroundProducer;
/*  11:    */ 
/*  12:    */ public class CaptchaUtil
/*  13:    */ {
/*  14:    */   public static String getCaptcha(HttpServletResponse response)
/*  15:    */   {
/*  16: 29 */     OutputStream os = null;
/*  17:    */     try
/*  18:    */     {
/*  19: 33 */       os = response.getOutputStream();
/*  20:    */       
/*  21: 35 */       Properties props = new Properties();
/*  22:    */       
/*  23: 37 */       String ext = "png";
/*  24:    */       
/*  25: 39 */       props.put("format", ext);
/*  26:    */       
/*  27: 41 */       props.put("font", "Helvetica");
/*  28:    */       
/*  29: 43 */       props.put("fontsize", "50");
/*  30:    */       
/*  31: 45 */       props.put("min-width", "150");
/*  32:    */       
/*  33: 47 */       props.put("padding-x", "10");
/*  34:    */       
/*  35: 49 */       props.put("padding-y", "10");
/*  36:    */       
/*  37: 51 */       props.put("curve", "false");
/*  38:    */       
/*  39: 53 */       FactorySimpleMathImpl solver = (FactorySimpleMathImpl)Producer.forName("org.smx.captcha.impl.FactorySimpleMathImpl");
/*  40:    */       
/*  41:    */ 
/*  42:    */ 
/*  43: 57 */       Properties instProps = new Properties();
/*  44:    */       
/*  45: 59 */       instProps.put("min", "2");
/*  46:    */       
/*  47: 61 */       instProps.put("max", "5");
/*  48:    */       
/*  49: 63 */       instProps.put("symbols", "1");
/*  50:    */       
/*  51: 65 */       solver.setProperties(instProps);
/*  52:    */       
/*  53:    */ 
/*  54: 68 */       IBackgroundProducer backGrid = new GridBackgroundProducer();
/*  55:    */       
/*  56: 70 */       Properties backProp = new Properties();
/*  57:    */       
/*  58: 72 */       backProp.put("background", "f6f6f6");
/*  59:    */       
/*  60: 74 */       backProp.put("frequency", "18");
/*  61:    */       
/*  62: 76 */       backGrid.setProperties(backProp);
/*  63:    */       
/*  64: 78 */       solver.setBackGroundImageProducer(backGrid);
/*  65:    */       
/*  66: 80 */       Producer.render(os, solver, props);
/*  67:    */       
/*  68: 82 */       return solver.getHashCode(solver.getLastWord());
/*  69:    */     }
/*  70:    */     catch (Exception e)
/*  71:    */     {
/*  72: 86 */       e.printStackTrace();
/*  73:    */     }
/*  74:    */     finally
/*  75:    */     {
/*  76:    */       try
/*  77:    */       {
/*  78: 91 */         os.flush();
/*  79:    */         
/*  80: 93 */         os.close();
/*  81:    */       }
/*  82:    */       catch (IOException e)
/*  83:    */       {
/*  84: 97 */         e.printStackTrace();
/*  85:    */       }
/*  86:    */     }
/*  87:101 */     return null;
/*  88:    */   }
/*  89:    */ }


/* Location:           D:\Users\Desktop\shanxi\项目\sxazmis\WEB-INF\classes\
 * Qualified Name:     com.rinsi.util.CaptchaUtil
 * JD-Core Version:    0.7.0.1
 */